
import { getToken } from '../../utils/auth'

interface activeSystem {
	permissionFlags: string
}

interface userInfoFace {
	menuList: any[]
	userName: string
}

const state = {
	userInfo: {
		menuList: [],
		userName: ''
	},
	token: getToken(),
	activeSystem: {},
	microAppData: {},
	menuList: [],
	flatMenuList: [],
	authFlatMenuList: [],
	hideMenu: ['productflow-inputBaseInfo', 'productflow-singleInfo']
}

const mutations = {
	SET_USERINFO: (state: any, data: userInfoFace) => {

	},
	SET_ACTIVESTSTEM: (state: any, activeSystem: activeSystem) => {
		sessionStorage.setItem('activeSystem', JSON.stringify(activeSystem))
		state.activeSystem = activeSystem
	},
	SET_MICROAPPDATA: (state: any, microAppData: object) => {

	},
	SET_MENULIST: (state: any, menuList: any[]) => {
		state.menuList = menuList
	},
	SET_FLATMENULIST: (state: any, list: any[]) => {
		state.flatMenuList = list
	},
	SET_AUTHFLATMENULIST: (state: any, list: any[]) => {
		state.authFlatMenuList = list
	}
}

const actions = {
	getUserInfo({ commit }: any) {

	},

	setActiveSystem({ commit }: any, obj: activeSystem) {
		commit('SET_ACTIVESTSTEM', obj)
	},

	setMicroApp({ commit }: any, obj: object) {

	},

	setMicroAppData({ commit }: any) {

	},

	setMenuList({ commit }: any, list: any[]) {
		commit('SET_MENULIST', list)
	}
}

export default {
	namespaced: true,
	state,
	mutations,
	actions
}
